package com.zy.modules.sys.repo;

import com.zy.modules.sys.entity.SysUserEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>user</p>
 * Created by zhezhiyong@163.com on 2017/7/25.
 */
public interface UserRepository extends PagingAndSortingRepository<SysUserEntity, Long>, JpaSpecificationExecutor<SysUserEntity> {

    @Modifying
    @Query("UPDATE SysUserEntity SET password = ?2 WHERE user_id = ?1 AND password = ?3")
    @Transactional
    int updatePassword(Long userId, String password, String newPassword);

    SysUserEntity findByUsername(String username);
}
